<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>服务报告列表</title>
		<!-- css代码 start -->
		<link href="../../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../../css/global.css" rel="stylesheet" />
		<link href="../../../../css/style.css" rel="stylesheet" />
		<style>
			.d_int_tp{
				border: 0 !important;
				margin-top: 6px !important;
			}
			.details_con .btm .selectBtn {
			    line-height: 28px;
			    color: #ffffff;
			    background: #ea1e1a;
			}
			
			.item_box .item .text{
				margin: 5px auto;
			}
			.item_box .item .text span.cen{
				margin-left:0;
			}
			.item_box .item .text span{
				width: auto;
				color: #333333;
			}
		</style>
		<!-- css代码 end -->
	</head>

	<body>
		<!-- html代码 start -->
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">服务报告列表</h1>
		</header>
		<div class="mui-content">
			<div class="details_con" style="margin: 0;">
				<div class="item_box" id="itemBox">
				</div>
			</div>
			<div style="height: 50px;"></div>
		</div>
		<!-- html代码 end -->
		
		<!-- js代码 start -->
		
		<!-- 基础js start -->
		<script src="../../../../js/mui.min.js"></script>
		<script src="../../../../js/utils/h.js"></script>
		<script src="../../../../js/constant.js"></script>
		<script src="../../../../js/common.js"></script>
		<script src="../../../../js/utils/base64.js"></script>
		<script src="../../../../js/utils/md5.js"></script>
		<script src="../../../../js/utils/sortMap.js"></script>
		<script src="../../../../js/utils/http.js"></script>
		<script src="../../../../js/app.js"></script>
		<!-- 基础js end -->
		
		<script type="text/javascript" charset="utf-8">
			var Instrument_id, serial_no, customer, starttime, endtime;
			
			(function($, doc) {
				$.init();
		
				$.plusReady(function() {
					var self = plus.webview.currentWebview();
					Instrument_id = self.Instrument_id;
					serial_no = self.serial_no;
					customer = self.customer;
					starttime = self.starttime;
					endtime = self.endtime;
					getList();
				});
			}(mui, document));
			
			// 查询列表
			function getList(){
				app.showWaiting('加载中...')
				
				ajaxGet(BASE_URL + "cc/instrument/syncAllServiceReport", {
					"Instrument_id": Instrument_id,
					"CustName": customer,
					"SerialNo": serial_no,
					"starttime": starttime,
					"endtime": endtime
				}, function(data) {
					app.closeWaiting()
					// console.log(JSON.stringify(data))
					if (data.code === 200) {
						var info = JSON.parse(data.data);
						var list = info.record;
						// console.log(JSON.stringify(list))
						if (list.length > 0) {
							var str = '';
							for(var c = 0;c<list.length;c++){
								 var id = list[c].EngRep_ID ? list[c].EngRep_ID : "";
								 var serviceNo = list[c].service_no ? list[c].service_no : "";
								 var customerName = list[c].customer ? list[c].customer : "";
								 var createTime = list[c].Create_time ? list[c].Create_time : "";
								 var model = list[c].model ? list[c].model : "";
								 str += '<div class="item" onclick="viewSignIn(\''+ serviceNo +'\', \''+ id +'\',\''+ id +'\')">';
								 str += '<div class="bar">';
								 str += '<span class="number"><img src="../../../../images/icon_204.png" />'+id+'</span>';
								 if(list[c].enginnerType){
									 str += '<span class="vip">'+list[c].enginnerType+'</span>';
								 }
								 str += '</div>';
								 str += '<div class="text autoHeight">';
								 // str += '<span class="l">客户名称：</span>';
								 str += '<span class="cen">'+customerName+'</span>';
								 str += '</div>';
								 str += '<div class="type">';
								 str += '<p><img src="../../../../images/check_cur1.png"/>创建时间：<span>'+createTime+'</span></p>';
								 str += '<p><img src="../../../../images/icon_203.png"/>仪器型号：<span>'+model+'</span></p>';
								 str += '</div>';
								 str += '</div>';
							 }
							 h('#itemBox').html(str);
						}else{
							var html = '<div class="nodata">—— 暂无数据 ——</div>';
							h("#itemBox").html(html);
						}
					} else {
						var html = '<div class="nodata">—— 暂无数据 ——</div>';
						h("#itemBox").html(html);
						app.toast(data.msg)
					}
				}, function(errorMsg) {
					app.closeWaiting();
					var html = '<div class="nodata">—— 暂无数据 ——</div>';
					h("#itemBox").html(html);
					app.toast("数据获取失败，请检查网络连接");
				});
			}
			
			// 跳转报告预览页（serviceNo、reportId必须，reportNo目前接口没有返回）
			function viewSignIn(serviceNo, reportId, reportNo){
				app.jumpTo('/view/service/report/preview/fuwunr.html', 'view/service/report/preview/fuwunr.html', {
					serviceNo,
					reportId,
					reportNo
				})
			}
		</script>
		<!-- js代码 end -->
	</body>

</html>
